home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1987 December / 1987-12.d64 / root race (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  7KB  |  188 lines

  1. 10 rem copyright 1987 compute! publications, inc. - all rights reserved
  2. 20 ifpeek(49155)<>14thengosub1600
  3. 30 dima(17,16),sc(17),v(17,16):x=rnd(-ti)
  4. 40 sys49152:fort=0to7:poke14336+160*8+t,255:next
  5. 50 print"[147]":fort=54272to54296:poket,0:next:poke54296,15
  6. 60 poke53272,31:poke53281,0:poke53280,11:h=1024:cl=54272+h:poke54278,240
  7. 70 poke53280,0:poke2040,13:poke54276,17:fc=252:fd=253
  8. 80 fort=0to127:poke832+t,0:next:fort=0to7:readx:poke832+t*3,x:next:poke53287,1
  9. 90 fort=0to9:readef(t):next:c(2)=15
  10. 100 input"[158]1 or 2 joysticks";jn:ifjn=1thenprint"[159]plug it in port one."
  11. 110 ifjn=0orjn>2then100
  12. 120 a$="[144][159][156][158][129][149][150][151][152][153][154][155]"
  13. 130 printc$"                     "
  14. 140 t=c(2):print"[154]select ground color with the space bar, and then hit f7."
  15. 150 ifpeek(203)=60thent=t+1:c(2)=t
  16. 160 c$=mid$(a$,(15andt)+1,1):forx=1to30:next:ifpeek(203)<>3then130
  17. 170 fort=1to15:pokeh+364+t*2,160:pokecl+364+t*2,t:next:poke198,0
  18. 180 input"[153]player one's root color (1-15)";c(0):c(0)=c(0)and15:ifc(0)=0then180
  19. 190 input"player two's root color (1-15)";c(1):c(1)=c(1)and15:ifc(1)=0then190
  20. 200 ifc(0)=c(1)thenprint"those colors are the same !!":goto180
  21. 210 poke198,0:input"[158]how many trees per player (3-9)";tn:iftn>9ortn<3then210
  22. 220 q=tn*2:print"select a game: f1=two players"
  23. 230 print"               f3=game demonstration"
  24. 240 print"               f5=player vs computer"
  25. 250 geta$:ifa$=""then250
  26. 260 ifa$<>"[133]"anda$<>"[134]"anda$<>"[135]"then250
  27. 270 p$(0)="computer one":p$(1)="computer two":ifa$="[134]"then330
  28. 280 ifa$="[135]"thenp$(0)="player 1":p$(1)="computer":input"[159]name";p$(0):goto330
  29. 290 input"[159]player one's name";p$(0):input"[155]player two's name";p$(1)
  30. 300 ifp$(0)="computer one"thenp$(0)="player one"
  31. 310 ifp$(1)="computer two"thenp$(1)="player two"
  32. 320 p$(0)=left$(p$(0),14):p$(1)=left$(p$(1),14)
  33. 330 fort=0toq-1:a(t,0)=t+2:next
  34. 340 gosub1420:poke53269,1:qz=0
  35. 350 u=56320:u2=56321:f=0
  36. 360 m=0:print"[146]"
  37. 370 pl=0:cm=a$="[134]":gosub1090:ifm=q-1-rcthenrc=rc+1:m=0:l=0
  38. 380 ifrc=q-2then420
  39. 390 pl=1:cm=(a$="[135]"ora$="[134]"):gosub1090:ifm=q-1-rcthenrc=rc+1:m=0:l=0
  40. 400 ifrc=q-2then420
  41. 410 goto370
  42. 420 s1=sc(a(0,q-2)-2):s2=sc(a(1,q-2)-2):b=(a(0,q-2)and1):pokefc,0
  43. 430 ifs1>s2andb=0thenk=0
  44. 440 ifs1>s2andb=1thenk=1
  45. 450 ifs2>s1andb=0thenk=1
  46. 460 ifs2>s1andb=1thenk=0
  47. 470 g$=p$(kand1)
  48. 480 poke53269,0:poke198,0:pokefd,0:g2$="s":ifabs(s1-s2)=1theng2$=""
  49. 490 fort=0to300:next
  50. 500 ifs1<>s2thenprint""sp$"the winner is [158]"g$", whose root"
  51. 510 ifs1=s2thenprint"[159]a tie game. (good defense by player 2)"
  52. 520 ifs1<>s2thenprint"system is"abs(s1-s2)"yard"g2$" larger."
  53. 530 readb,d,x:ifb<0then550
  54. 540 poke54272,d:pokefc,b:fort=1tox*88:next:goto530
  55. 550 poke54272,0:pokefc,0:restore:fort=1to18:readx:next
  56. 560 print"[153]    play same game again? (y<< >>n)";
  57. 570 ifpeek(203)=39orpeek(u2)=247thenprint"[147]":j=1:goto600
  58. 580 ifpeek(203)=25orpeek(u2)=251thenj=2:goto600
  59. 590 goto570
  60. 600 print"[147]":fort=0to17:forx=0to16:sc(t)=0:a(t,x)=0:next:next:rc=0:lg=0
  61. 610 onjgoto120,330
  62. 620 e=0:print"                           ";
  63. 630 ifrx+d>q-rc-2then780
  64. 640 ifrx+d<0then780
  65. 650 ifa(rx+d,rc+1)and1<>0then780
  66. 660 b=int(rnd(-ti)*5):pokefd,0:pokefc,ef(b*2):pokefd,ef(b*2+1)
  67. 670 a(rx+d,rc+1)=a(rx,rc):sc(a(rx,rc)-2)=sc(a(rx,rc)-2)+1:v(rx+d,rc+1)=d+2
  68. 680 t=int(rnd(0)*3)*4
  69. 690 ifdthen730
  70. 700 ifpeek(x+h)<>143thenpokex+h,140+t/4:goto720
  71. 710 pokeh+x,130+t
  72. 720 pokex+h+1,131+t:pokex+cl,c(pl):pokex+cl+1,c(pl)
  73. 730 ifnotdthen770
  74. 740 pokex+h-1,128+t:pokex+cl-1,c(pl):pokex+cl,c(pl)
  75. 750 ifpeek(x+h)<>143thenpokex+h,140+t/4:goto770
  76. 760 pokeh+x,129+t
  77. 770 m=m+1:return
  78. 780 e=-1:return
  79. 790 pokefd,0:pokefc,2:poke54276,33
  80. 800 print"[153]no moves are possible for "p$(pl);:fort=1to2000:next
  81. 810 pokefc,0:poke54276,17:return
  82. 820 ifxt>0thenifa(xt-1,ry)and1=0anda(xt+1,ry)and1=0thendd=notdd
  83. 830 ifxt=0thenxt=1:dd=0
  84. 840 return
  85. 850 ff=0:d=1:ifrx<0thenrx=0
  86. 860 ifrc=0andf=<tn-2thenf=f+1:rx=tn-1:goto1120
  87. 870 iff>1andrc>0thenrx=int(tn-ry/2)-1:ifrx<0thenrx=0
  88. 880 ff=-1:ifry>1then920
  89. 890 dd=-1:ifrx>0thenif(-a(rx-1,ry)and1)thenif-a(rx+1,ry)and1thenrx=rx-1:goto890
  90. 900 ifrx>0thenif(-a(rx-1,ry)and1)and(a(rx+1,ry)and1=0)thendd=0
  91. 910 goto1120
  92. 920 fort=0totn*2:if(a(t,1)and1)=0thennext
  93. 930 ift=tnthenif-(tnand1)thencs=-1:tr=tn+2:goto980
  94. 940 ift=tn-1thenif(tnand1)=0thencs=-1:tr=tn+3:qz=-1:goto970
  95. 950 lg=0:fort=3totn*2-5step2:ifsc(t)>lgthenlg=sc(t):tr=t+2
  96. 960 next:cs=0:iftr-2>tnthencs=-1
  97. 970 ifcs=0then1040
  98. 980 dd=-1:fort=1totn*2-ry-1:ifa(t,ry)<>trthennext
  99. 990 xt=t
  100. 1000 if(ry>tn-1)thenif(-a(xt+1,ry)and1)and(a(0,ry)and1=1)thenxt=xt+1
  101. 1010 dd=0:goto1000
  102. 1020 ifqzthenrx=xt:dd=-1:goto1120
  103. 1030 goto1080
  104. 1040 d=1:dd=0:fort=tn*2-ryto1step-1:ifa(t,ry)<>trora(t,ry+1)>0thennext
  105. 1050 xt=t
  106. 1060 ifry>tn-1andxt>0thenif(-a(xt-1,ry)and1)thenxt=xt-1:dd=-1:goto1060
  107. 1070 ifpeek(203)=2thenend
  108. 1080 gosub820:rx=xt:goto1120
  109. 1090 print""sp$;""p$(pl)"'s move..";:rx=0:ry=rc:d=1
  110. 1100 poke53269,0:b=0:e=0:ff=0:ifcmthenrx=int(rnd(1)*(q-ry-2))
  111. 1110 ifa$="[135]"andpl=1then850
  112. 1120 if(rx>q-rc-1)andbthenrx=0
  113. 1130 if(rx<0)andbthenrx=q-rc-1
  114. 1140 ifrx>q-rc-1andnotbthene=e+1:rx=0
  115. 1150 ifrx<0andnotbthene=e+1:rx=q-rc-1
  116. 1160 py=99+rc*8:px=(ce+rc)*8+24+rx*16:ife>1then790
  117. 1170 if(a(rx,rc)and1)<>plthenrx=rx+d:goto1120
  118. 1180 x=int((px-24)/8)+int((py-50)/8)*40
  119. 1190 ifpeek(x+h+1)<>148andpeek(x+h-1)<>148thenrx=rx+d:goto1120
  120. 1200 ifpx>255thenpoke53264,1
  121. 1210 ifpx<256thenpoke53264,0
  122. 1220 poke53248,pxand255:poke53249,py:b=-1:poke53269,1
  123. 1230 ifnotcmthen1270
  124. 1240 d=int(rnd(1)*2)-1:ifffthend=dd
  125. 1250 gosub620:ifethend=int(rnd(1)*2)-1:goto1250
  126. 1260 return
  127. 1270 j=1:ifpl=1andjn=2thenpoke56322,0:j=0
  128. 1280 if(peek(u+j)and8)=0thenrx=rx+1:d=1:goto1100
  129. 1290 if(peek(u+j)and4)=0thenrx=rx-1:d=-1:goto1100
  130. 1300 pokeu,127
  131. 1310 if(peek(u+j)and16)>0then1270
  132. 1320 print"[146]which way???                   ";
  133. 1330 d=-2
  134. 1340 if(peek(u+j)and8)=0thend=0
  135. 1350 if(peek(u+j)and4)=0thend=-1
  136. 1360 poke56322,255
  137. 1370 ifd=-2then1340
  138. 1380 gosub620:ifnotethenreturn
  139. 1390 print"     [158]i m p o s s i b l e   m o v e"
  140. 1400 pokefd,0:poke54276,33:fork=0to5*(NULL)step.2:pokefc,abs(sin(k)*9)+3:next
  141. 1410 poke54276,17:pokefc,0:goto1090
  142. 1420 sp$="                                        ":ce=20-q:g$="":g2$=""
  143. 1430 print"[147]"sp$c$""
  144. 1440 fort=2toce:g$=g$+" ":next:g$=g$+"u"
  145. 1450 fort=1toce:g2$=g2$+" ":next:g2$="v"+g2$
  146. 1460 d$="ot":fort=1toq-2:d$=d$+"ot":next:d$=d$+"o"
  147. 1470 g$=""+g$
  148. 1480 x=160+h+ce:x2=160+cl+ce:fort=0totn-1:pokex+t*4,147:pokex2+t*4,c(0)
  149. 1490 pokex+t*4+40,146:pokex2+t*4+40,c(0):pokex+t*4+2,145:pokex2+t*4+2,c(1)
  150. 1500 pokex+t*4+42,144:pokex2+t*4+42,c(1)
  151. 1510 next
  152. 1520 fort=1toq-2
  153. 1530 printg$"[152]"d$c$g2$;:d$=left$(d$,len(d$)-2):g2$=g2$+" "
  154. 1540 g$=" "+g$
  155. 1550 next
  156. 1560 iftn<10thenfort=1to(10-tn)*2:printsp$;:next
  157. 1570 t=(10-tn)*2
  158. 1580 fork=0to2:poke56276-k-t*40,14:next
  159. 1590 print"";:return
  160. 1600 poke53281,1:poke53280,1:print"[147][129]   copyright 1987 compute! pub., inc."
  161. 1610 printtab(10)"all rights reserved"
  162. 1620 printtab(11)"r o o t   r a c e"
  163. 1630 fori=1to350:reada:x=x+a:next
  164. 1640 ifx<>25073thenprint"error in data statements.":stop
  165. 1650 restore:fort=1to66:readx:next
  166. 1660 fort=0to99:readx:poke49152+t,x:next:fort=0to183:readx:poke15360+t,x:next
  167. 1670 restore:return
  168. 1680 data 24,60,126,255,219,24,24,24,18,70,16,16,21,113,18,50,5,131
  169. 1690 data 16,195,1.5,14,239,1,16,195,1.5,18,209,1,16,195,1.5
  170. 1700 data 18,209,1,21,31,1.5,18,209,1,42,62,1.5,31,165,1,42,62,1.5
  171. 1710 data 31,165,1,18,209,1.5,31,165,1,50,60,2.5,-1,-1,-1
  172. 1720 data 169,0,141,14,220,169,251,37,1,133,1,162,0,189,0,208,157,0,56
  173. 1730 data 189,0,209,157,0,57,232,208,241,165,1,9,4,133,1,169,1,141,14
  174. 1740 data 220,169,27,141,17,208,169,127,141,13,220,169,65,141,20,3,169,192,141
  175. 1750 data 21,3,169,129,141,26,208,96,165,252,240,5,24,101,253,133,252,141,1
  176. 1760 data 212,169,1,141,25,208,169,0,141,18,208,173,13,220,41,1,240,3,76
  177. 1770 data 49,234,76,188,254
  178. 1780 data 0,0,0,3,6,12,24,24,24,24,48,224,0,0,0,0,24,24,48,51,30
  179. 1790 data 0,0,0,0,0,0,224,48,24,24,24,0,0,0,1,3,6,12,24,24,24,112,192
  180. 1800 data 0,0,0,0,24,24,12,6,3,0,0,0,0
  181. 1810 data 0,0,192,240,24,24,24,0,0,0,15,24,48,48,24,24,112,192,128
  182. 1820 data 0,0,0,0,24,12,12,7,0,0,0,0,0,0,0,0,224,48,24
  183. 1830 data 24,24,24,60,231,129,0,0,0,28,54,99,